import { createRouteMap } from './createRouteMap.js';

export function createMatch(routes) {
  // console.log("router", routes);
  const { pathList, pathMap, nameMap } = createRouteMap(routes);
  console.log(pathList, pathMap, nameMap);
  // 进一步处理 pathList, pathMap, nameMap
  function addRoute(r) { // 动态添加路由
    createRouteMap([r],pathMap);
  }
  function addRoutes(r) {
    createRouteMap(r,pathMap);
  }
  function match(location) {
    return pathMap[location];
  }
  function getRoute() {}
  return {
    addRoute, // 添加一个路由
    addRoutes, // 添加多个路由
    getRoute, // 获取路由
    match, // 匹配路由
  };
}
